package io.renren.entity;

import cn.hutool.core.bean.BeanUtil;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import io.renren.param.RefreshEslParam;
import lombok.Data;

import java.io.Serializable;
import java.util.Date;

/**
 * 基础
 *
 * @author 1
 * @email 1@2.com
 * @date 2021-09-17 15:57:01
 */
@Data
@TableName("esl_refresh_log")
public class EslRefreshLogEntity implements Serializable {
	private static final long serialVersionUID = 1L;

	/**
	 *
	 */
	@TableId
	private Long id;
	/**
	 * 用户（公司id)
	 */
	private String user;
	/**
	 * 墨水屏id
	 */
	private String eslId;
	/**
	 * eslWorking接口地址
	 */
	private String ewUrl;
	/**
	 * 刷新参数
	 */
	private String params;
	/**
	 * 刷新次数
	 */
	private Integer refreshNum;

	private Date createTime;

	private Date updateTime;

	private String sid;

	public static EslRefreshLogEntity createFor(String url, String jsonStr, RefreshEslParam param) {
		EslRefreshLogEntity eslRefreshLogEntity = new EslRefreshLogEntity();
		BeanUtil.copyProperties(param, eslRefreshLogEntity);
		eslRefreshLogEntity.setUser(param.getCompId());
		eslRefreshLogEntity.setEslId(param.getEsl_id());
		eslRefreshLogEntity.setEwUrl(url);
		eslRefreshLogEntity.setParams(jsonStr);
		eslRefreshLogEntity.setRefreshNum(0);
		eslRefreshLogEntity.setCreateTime(new Date());
		eslRefreshLogEntity.setUpdateTime(new Date());
		return eslRefreshLogEntity;
	}
}
